<?php
include_once('./header.php');
$res = select($config,'article','where id='.$_GET['id']);
$commentres = select($config,'comment','where aid='.$_GET['id']);
foreach($commentres as $k=>$v){
	$user = select($config,'user','where id='.$v['uid']);
	$commentres[$k]['uid'] = $user[0]['uname'];
	$commentres[$k]['pic'] = $user[0]['pic'];
}
// var_dump($commentres);die;
?>
		
</head>
<body>

	<!-- SITE WRAPPER -->
	<div id="wrapper">
	
		<!-- PAGE WITH CONTENTS -->
		<div id="page">
			<div id="content">
							
				<h1><?php echo $res[0]['title'] ?></h1>
				
				<div class="hr"></div>
				
				<!-- LARGE /public/IMAGE WITH FANCYBOX -->
				<span class="large_/public/image">
					<a href="/public/images/pic-tn-large.jpg" rel="" class="fancybox">
						<span class="imghover_large"></span>
						<img src="/public/upload/<?php echo $res[0]['pic'] ?>" width="582" height="184" alt="" />
					</a>
				</span>
				
				<div class="vspace"></div>
				<?php echo htmlentities($res[0]['content']) ?>
				<div class="hr2"></div>
			
				<!-- POST INFO -->
				<p class="blog-post-info">&nbsp;
					<img src="/public/images/icon-time.png" alt="" />&nbsp;<?php echo date('M d,Y',$res[0]['ctime']) ?>&nbsp;&nbsp;
					<img src="/public/images/sep.gif" alt="" />&nbsp;&nbsp;
					<img src="/public/images/icon-category.png" alt="" />&nbsp;<?php echo $res[0]['tag'] ?>&nbsp;&nbsp;
					<img src="/public/images/sep.gif" alt="" />&nbsp;&nbsp;
					<img src="/public/images/icon-comment.png" alt="" />&nbsp;0 Comment(s)&nbsp;&nbsp;
				</p>
				
				<div class="hr2"></div>
			
				<!-- COMMENTS -->
				<h2>评论</h2>				
				
				<ul id="comments-list">
					<?php
						foreach($commentres as $v){
					?>
					<li>					
						<div class="comments-avatar">
							<img alt="" src="/public/upload/<?php echo $v['pic'] ?>" class="avatar" height="60" width="60" />
						</div>
						<div class="comments-text">
						<?php echo date('M d,Y .h:i A',$v['ctime']) ?>
							<br /><b class="uname"><?php echo $v['uid'] ?></b><br /><?php echo $v['comment'] ?>
							<br /><br />
							<a class="reply" id="<?php echo $v['id'] ?>">Reply</a>
						</div>		
					</li>
					<?php
						}
					?>
				</ul>
				
				<div class="hr2"></div>

				<!-- COMMENTS REPLY -->
				<h2>Leave a Comment</h2>	

				<form action="addcommit.php" method="post">
					<input type="hidden" name="aid" value="<?php echo $res[0]['id'] ?>">
					<input type="hidden" name="pid" value="0">
				<ul id="respond">
					<li>
						<textarea rows="" cols="" class="comment-textarea" name="comment"></textarea>
					</li>
					<li>
						<input type="submit" id="submit_btn"/>
					</li>
				</ul>
				</form>
			</div><!-- #content ends -->	
		</div><!-- #page ends -->
			
		
		<!-- SIDEBAR -->
		<?php include_once('./public/public.php') ?>
			
		</div><!-- #sidebar ends -->			
					
	</div><!-- #wrapper ends -->

	
	<!-- BACKGROUND SLIDER -->
	<div id="bg_slider">	
		<img src="/public/images/bgslider-1.jpg" alt="" />
		<img src="/public/images/bgslider-2.jpg" alt="" />
		<img src="/public/images/bgslider-3.jpg" alt="" />
	</div>

	<script>
		$(".reply").click(function(){
			var aid = $(this).attr('id');
			var i = $('.reply').index($(this));
			var uname = $(".uname").eq(i).html();
			$("input[name='pid']").val(aid);
			$("textarea").html('@'+uname+'&nbsp;&nbsp;');
		})
	</script>
</body>
</html>